<template>
	<!-- 商铺管理 -->
	<view class="s_wp">
		<view class="commission_nav" v-if="!pmid">
			<view class="commission_n_item">
				<view>开店总数</view>
				<view class="commission_nav_number">{{openShop.tsupnum||0}}</view>
			</view>
			<view class="commission_n_item">
				<view>可开店</view>
				<view class="commission_nav_number">{{openShop.supnum||0}}</view>
			</view>
			<!-- <view class="commission_n_item">
				<view>团长总数</view>
				<view class="commission_nav_number">{{openShop.trefernum||0}}</view>
			</view>
			<view class="commission_n_item">
				<view>剩余团长</view>
				<view class="commission_nav_number">{{openShop.refernum||0}}</view>
			</view> -->
		</view>
		<view class="tran_cate flex_between" v-if="!pmid">
			<view class="tran_cate_item" :class="{'tran_cate_item_ac':type==1}" @click="changeType(1)">我收到的</view>
			<view class="tran_cate_item" :class="{'tran_cate_item_ac':type==2}" @click="changeType(2)">我划出的</view>
		</view>
		<view class="list" v-if="list.length>0">
			<view class="item" v-for="(item,index) in list" :key="item.id">
				<view class="info">
					<view class="tit clamp">划拨人：{{item.fnickname}}</view>
					<view class="tit clamp">接收人：{{item.nickname}}</view>
					<view class="type">划拨店铺数量：{{item.supnum}}</view>
					<!-- <view class="type">划拨团长数量：{{item.refernum}}</view> -->
					<view class="name">划拨时间：{{item.createtime}}</view>
				</view>
			</view>
		</view>
		<view class="empty_loading">
			<image v-show="isloading" src="/static/business/loading.gif" mode=""></image>
			<text v-show="!ismore">到底了~</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				isloading: false,
				ismore: false,
				page: 0,
				pmid: 0,
				openShop: [],
				type: 1,
			};
		},
		onLoad(option) {
			if(option.pmid){
				this.pmid = option.pmid;
				this.getlist();
			}else{
				this.getlist2();
				this.getNum();
			}
		},
		onReachBottom(){
			if(this.pmid==0){
				this.getlist2();
			}else{
				this.getlist();
			}
		},
		methods: {
			changeType(id){
				if(id==this.type) return;
				this.type = id;
				this.page = 0;
				this.list = [];
				if(this.pmid==0){
					this.getlist2();
				}else{
					this.getlist();
				}
			},
			getlist(id) {
				this.page++;
				this.isloading = true;
				this.$axios('salecenter/hlist', 'POST', 'member',{
					page: this.page,
					pmid: this.pmid,
					type: this.type,
				}).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.list = [...this.list, ...res.data.data.list];
						this.ismore = res.data.data.list.length > 0;
					}
				})
			},
			getlist2(){
				this.page++;
				this.isloading = true;
				this.$axios('salecenter/hlist', 'POST', 'member',{
					page: this.page,
					type: this.type,
				}).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.list = [...this.list, ...res.data.data.list];
						this.ismore = res.data.data.list.length > 0;
					}
				})
			},
			getNum(){
				this.$axios('salecenter/pmain', 'POST', 'member').then(res => {
					if (res.data.code == 200) {
						this.openShop = res.data.data.info;
					}
				})
			}
		}
	}
</script>

<style lang="scss">
page{
	background: #FBF8FE;
	padding-bottom: 170rpx;
}
.s_wp {
		overflow: hidden;
		padding: 20rpx;
	}
	.commission_nav {
		background: linear-gradient( 135deg, #B92DF1 0%, #8A17E2 100%);
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: space-around;
		height: 204rpx;
		border-radius: 24rpx;
		text-align: center;
		font-size: 24rpx;
		margin-top: -10rpx;
		margin-bottom: 20rpx;
		.com_line{
			width: 2rpx;
			height: 50rpx;
			background: rgba(255,255,255,.7);
		}
		.commission_nav_number {
			font-size: 46rpx;
			font-weight: 600;
		}
	}
	.tran_cate{
		margin-bottom: 20rpx;
		.tran_cate_item{
			line-height: 70rpx;
			width: 48%;
			text-align: center;
			background: #fff;
			color: #999999;
			border-radius: 12rpx;
		}
		.tran_cate_item_ac{
			background: #F0E1FF;
			color: #8615E1;
			font-weight: bold;
		}
	}
	.list{
		.item{
			background: #FFFFFF;
			border-radius: 12rpx;
			padding: 20rpx;
			margin-bottom: 20rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
				image{
					width: 144rpx;
					height: 144rpx;
					border-radius: 12rpx;
				}
				.info{
					// width: calc(100% - 254rpx);
					width: 100%;
					// padding-left: 20rpx;
					font-size: 26rpx;
					line-height: 1.8;
					.tit{
						font-size: 30rpx;
						color: #333333;
						font-weight: 600;
					}
					.type{
						color: #8615E1;
					}
					.name{
						color: #999999;
					}
					.i_type{
						background: linear-gradient( 180deg, #D9DFFF 0%, #F2F4FF 100%);
						padding: 4rpx 6rpx;
						color: #303EA9;
						border-radius: 8rpx;
						float: right;
					}
					.i_type2{
						background: linear-gradient( 180deg, #FFE5D9 0%, #FFF6F2 100%);
					}
				}
				.btn{
					width: 110rpx;
					height: 60rpx;
					background: #FBF8FE;
					border-radius: 30rpx;
					line-height: 60rpx;
					text-align: center;
				}
		}
	}
	.bottom{
		width: 100%;
		height: 148rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 4rpx 22rpx 0rpx #F3E8FC;
		position: fixed;
		bottom: 0;
		.s_add {
			width: 396rpx;
			height: 74rpx;
			background: linear-gradient( 270deg, #8917E2 0%, #B92DF1 100%);
			border-radius: 38rpx;
			font-size: 28rpx;
			color: #FFFFFF;
			line-height: 74rpx;
			text-align: center;
			margin: 30rpx auto;
		}
	}
</style>
